/*
 * core_internal.h
 *
 *  Created on: 2012/07/10
 *      Author: guanxiaoying
 */

#ifndef CORE_INTERNAL_H_
#define CORE_INTERNAL_H_

#define    OPTID_NONE  0
#define 	OPTID_CMPLKIND	1
#define 	OPTID_PTRDIFF_TYPE	2
#define 	OPTID_SIZEOF_TYPE	3
#define 	OPTID_ENUMTYPE	4
#define 	OPTID_CHAR_UNSIGNED	6
#define 	OPTID_BIT_UNSIGNED	7
#define 	OPTID_BIT_SIGNED	8
#define 	OPTID_NEARFAR	9
#define 	OPTID_SHIFT_BITNUM_REMAINDER	10
#define 	OPTID_SHIFT_BITNUM_ALL	11
#define 	OPTID_SHIFT_KIND_ARITH	12
#define 	OPTID_SHIFT_KIND_LOGICAL	13
#define 	OPTID_MODULO_SIGNED	14
#define 	OPTID_MODULO_UNSIGNED	15
#define 	OPTID_BREAK_PPNUM	16
#define 	OPTID_BIT_TYPE	17
#define 	OPTID_CPPCOMMENT	18
#define 	OPTID_CPPRESULT	19
#define 	OPTID_SRC_MACRO	20
#define 	OPTID_FUNCTION_MACRO	21
#define 	OPTID_MAX_ALIGNMENT	24
#define 	OPTID_BITBYTE_NEW	25
#define 	OPTID_BYTEBIT_NEW	26
#define 	OPTID_BITBIT_BYSIZE	27
#define 	OPTID_DIVIDE_BIT	28
#define 	OPTID_ZEROBIT	29
#define 	OPTID_BITBIT_ARRAGNE	30
#define 	OPTID_POINTERSIZE	31
#define 	OPTID_NEAR_POINTERSIZE	32
#define 	OPTID_FAR_POINTERSIZE	33
#define 	OPTID_SHORTSIZE	34
#define 	OPTID_INTSIZE	35
#define 	OPTID_LONGSIZE	36
#define 	OPTID_FLOATSIZE	37
#define 	OPTID_DBLSZIE	38
#define 	OPTID_LONGDBLSIZE	39
#define 	OPTID_C90		40
#define 	OPTID_C99		41
#define 	OPTID_GNU		42
#define 	OPTID_I_SYM		43
#define 	OPTID_I_USER	44

#define   OPTID_BUILDINFUNC 46
#define 	OPTID_DMACRO	47
#define 	OPTID_UMACRO	48
#define 	OPTID_NMACRO	49
#define 	OPTID_SKIPOPT	0

#define 	OPT_CHAR_UNSIGNED		101
#define 	OPT_CHAR_SIGNED		102
#define 	OPT_BIT_UNSIGNED		103
#define 	OPT_BIT_SIGNED		104
#define 	OPT_BIT_BYTYPE		105
#define 	OPT_SHIFT_ARITH		106
#define 	OPT_SHIFT_LOGICAL		107
#define 	OPT_MODULO_SIGNED		108
#define 	OPT_MODULO_UNSIGNED		109
#define 	OPT_MODULO_BYDIVIDEND		110
#define 	OPT_SHIFT_BITNUM_REMAINDER		111
#define 	OPT_SHIFT_BITNUM_ALL		112
#define 	OPT_DEFMCR      	113
#define 	OPT_UNDEFMCR    	114
#define 	OPT_DISABLED_MCR    	115
#define    OPT_INC_USR  116
#define    OPT_INC_SYS  117
#define    OPT_SHIFT_NEG_2_UNSIGNED  118
#define    OPT_SHIFT_NEG_CHANGE_OP   119


#define OPERAND_OBJECT 1
#define OPERAND_FUNCTION 2
#define OPERAND_RESULT 3
#define OPERAND_CONSTANT 4
#define OPERAND_CONSTSTRING 5

#define ASM_CMD_NOP   0
#define ASM_CMD_RETURN  3
#define ASM_CMD_CHOOSE 6
#define ASM_CMD_CHOOSEEND 7
#define ASM_CMD_CONFLUX  8
#define ASM_CMD_JUMP  9
#define ASM_CMD_JUDGE  10
#define ASM_CMD_BRANCH  11
#define ASM_CMD_FUNCENTRY  12
#define ASM_CMD_FUNCEXIT   13
#define ASM_CMD_GETOPERAND  100
#define ASM_CMD_GETOFFSET_UNIT   101
#define ASM_CMD_GETOFFSET    102
#define ASM_CMD_GETMEMDATA   103
#define ASM_CMD_GETADDR  104
#define ASM_CMD_CALL  105
#define ASM_CMD_INC  106
#define ASM_CMD_DEC  107
#define ASM_CMD_MINUS  108
#define ASM_CMD_NEGATION 109
#define ASM_CMD_BITNEGATION 110
#define ASM_CMD_CAST   111
#define ASM_CMD_MUL   112
#define ASM_CMD_DIV   113
#define ASM_CMD_MOD   114
#define ASM_CMD_ADD  115
#define ASM_CMD_SUB  116
#define ASM_CMD_LSFT   117
#define ASM_CMD_RSFT   118
#define ASM_CMD_GREATER   119
#define ASM_CMD_GREATEREQUAL   120
#define ASM_CMD_LESS   121
#define ASM_CMD_LESSEQUAL   122
#define ASM_CMD_EQUAL   123
#define ASM_CMD_UNEQUAL   124
#define ASM_CMD_BITAND   125
#define ASM_CMD_BITEXOR   126
#define ASM_CMD_BITINOR  127
#define ASM_CMD_LGAND   128
#define ASM_CMD_LGOR   129
#define ASM_CMD_ASSIGN   130
#define ASM_CMD_ASSIGNARG   131


#define S8_MAXVALUE  ((S8)0x7FFFFFFFFFFFFFFFLL)
#define S8_MINVALUE  ((S8)0x8000000000000000LL)
#define U8_MAXVALUE  ((U8)0xFFFFFFFFFFFFFFFFULL)
#define U8_MINVALUE  ((U8)0x0ULL)

#define S4_MAXVALUE  ((S4)0x7FFFFFFF)
#define S4_MINVALUE  ((S4)0x80000000)
#define U4_MAXVALUE  ((U4)0xFFFFFFFFUL)
#define U4_MINVALUE  ((U4)0x0UL)
#define S2_MAXVALUE  ((S2)0x00007FFF)
#define S2_MINVALUE  ((S2)0xFFFF8000)
#define U2_MAXVALUE  ((U2)0x0000FFFF)
#define U2_MINVALUE  ((U2)0x0)
#define U1_MAXVALUE  ((UCHAR)0x000000FF)
#define U1_MINVALUE  ((UCHAR)0x0)
#define S1_MAXVALUE  ((SCHAR)0x0000007F)
#define S1_MINVALUE  ((SCHAR)0xFFFFFF80)

/*サイズの型*/
#define	VARSIZE_NONE 		0
#define VARSIZE_CHAR		1
#define VARSIZE_SHORT		2
#define VARSIZE_INT			3
#define VARSIZE_LONG		4
#define VARSIZE_FLOAT		5
#define VARSIZE_DOUBLE		6
#define VARSIZE_LONGDOUBLE  7
#define VARSIZE_POINTER		8
#define VARSIZE_FARPOINTER	9
#define VARSIZE_NEARPOINTER 10
#define VARSIZE_LONGLONG    11
#define VARSIZE_WCHAR       12

#define CHARBIT 8
/* サイズマクロ */
#define 	CHARSIZE			( stVarSizeInfo[VARSIZE_CHAR-1].usVarSize )
#define 	SHORTSIZE			( stVarSizeInfo[VARSIZE_SHORT-1].usVarSize )
#define 	INTSIZE				( stVarSizeInfo[VARSIZE_INT-1].usVarSize )
#define 	LONGSIZE			( stVarSizeInfo[VARSIZE_LONG-1].usVarSize )
#define 	FLOATSIZE			( stVarSizeInfo[VARSIZE_FLOAT-1].usVarSize )
#define 	DOUBLESIZE			( stVarSizeInfo[VARSIZE_DOUBLE-1].usVarSize )
#define 	LONGDOUBLESIZE		( stVarSizeInfo[VARSIZE_LONGDOUBLE-1].usVarSize )
#define 	POINTERSIZE			( stVarSizeInfo[VARSIZE_POINTER-1].usVarSize )
#define    FARPOINTERSIZE		( stVarSizeInfo[VARSIZE_FARPOINTER-1].usVarSize )
#define    NEARPOINTERSIZE		( stVarSizeInfo[VARSIZE_NEARPOINTER-1].usVarSize )
#define    LONGLONGSIZE		( stVarSizeInfo[VARSIZE_LONGLONG-1].usVarSize )
#define    WCHARSIZE		( stVarSizeInfo[VARSIZE_WCHAR-1].usVarSize )

typedef struct _VARVALUE_8{
	SCHAR  sign;
	SCHAR  overflow;
	U4	u4Quotient;                     /* Symbol */
	U8	u8Remainder;                        /* Absolute value */
}VARVALUE;

typedef struct _VARSIZEINFO{
	PSZ		pszVarName;			/* 変数型名 		*/
	U2	usVarID;			/* ｱｸｾｽID  		*/
	U2	usVarSize;			/* 変数型ｻｲｽﾞ		*/
	U2	usChangeSize;   	/* ｻｲｽﾞ変更されたか */
}VARSIZEINFO ;
extern VARSIZEINFO stVarSizeInfo[] ;

/*  変数定義　************************/
/* 構造体の定義 */
typedef struct _COREENVINFO{
	U4  ulCallBackEvent ;
    U4  ulCplKind ;
    UCHAR usMaxBitWidth ;
    UCHAR  ucCharSign ;
    UCHAR  ucBitSign ;
    UCHAR  ucBitType;
    UCHAR  ucNearFar;
    UCHAR  ucShiftKind ;
    UCHAR  ucModuloSign ;
    UCHAR  ucBreakPPNum;
    UCHAR  ucShiftWhenOverflow;
    UCHAR  ucShiftWhenNegative;
    UCHAR  ucCppComment;
    UCHAR  ucCppResult;
    UCHAR  ucSrcNameMcr;
    UCHAR  ucFuncNameMcr;
    UCHAR  ucDelConstExpr;
    UCHAR  ucCompressExpr;
    UCHAR  ucBitByte_new_align;
    UCHAR  ucByteBit_new_align;
    UCHAR  ucBitBit_size_alignment;
    UCHAR  ucBit_divide;
    UCHAR  ucBit_zero_self;
    UCHAR  ucBitBit_arrange_bysize;
    UCHAR  ucMaxAlignment;
    UCHAR  ucC90;
    UCHAR  ucC99;
    UCHAR  ucGNU;
    AST  astEnumType ;
    AST  astEnumBegin;
    AST  astEnumEnd;
    AST  astSizeofType ;
    AST  astDiffPtrType ;
}COREENVINFO ;

extern COREENVINFO stCoreEnvInfo ;
#endif /* CORE_INTERNAL_H_ */
